package com.xxx.data;

import sun.rmi.runtime.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/19  14:53
 * @Copyright
 */
public class dataDome01 {
    public static void main(String[] args) throws ParseException {
//        m1();
//        m2()

        //2008-08-08距离现在多少天

        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long s = date.getTime();
        System.out.println(s);

        String s2 = "2008-08-19 15:27:33";
        Date data01 = format.parse(s2);
        long data02 = data01.getTime();
        System.out.println(data02);
        System.out.println((s - data02) /1000/60/60/24);


    }


    private static void m1() {
        Date date = new Date();
        System.out.println(date);
        long time = date.getTime();
        String s2 = "2008-08-19 15:27:33";

    }


    private static void m2() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s = format.format(new Date());
        System.out.println(s);

        String s2 = "2021-08-19 15:27:33";
        try {
            Date date = format.parse(s2);
            System.out.println(date);
        } catch (ParseException e) {
            e.printStackTrace();

        }
    }
}





